<?php

/**
 * @author thihien
 * @copyright 2011
 */

include_once('includes/general.php');
if(!tep_db_checkDb()) die('khong ket noi dc csdl');
$content='';
$chuoi='';
if(isset($_POST['send']) && $_POST['send']!=""){
    if(isset($_POST['name']) && $_POST['name']!=""){
        $hoten=$_POST['name'];
    }else{
        $chuoi.='Chưa nhập họ tên.</br>';
    }
    
      if(isset($_POST['email']) && $_POST['email']!=""){
        $email=$_POST['email'];
    }else{
        
        $chuoi.='Chưa nhập email.</br>';
    }
    
      if(isset($_POST['noidung']) && $_POST['noidung']!=""){
        $noidung=$_POST['noidung'];
    }else{
        $chuoi.='Chưa nhập nội dung.</br>';
    }
   
    if($chuoi==""){
        $sql="INSERT INTO lienhe(ten,email,noidung)values('$hoten','$email','$noidung')";
        $kq=tep_db_query($sql);
        if($kq>0){
            
           #$chuoi.="<span style='color:red';> </span></br></br>";
           echo "<script type=\"text/javascript\">alert('Thank you for sending mail to us!');</script>";
        }
        else{
            echo "<script type=\"text/javascript\">alert('you sent failed! please resend!');</script>";
        }
    }
}


$content.='
    <div id="center">
   
    <div id="thongtincongty">
        <div class="title"><h3>contact us </h3></div>';
        $sql3='select * from thongtincongty';
        $kq3=tep_db_query($sql3);
        $item2=tep_db_fetch_array($kq3);
     $content.='<div id="tieude_ct">'.$item2['tieude'].'</div>
        <div id="noidung_ct">'.$item2['noidung'].'</div>    
    </div>
    <form  id="fr_lienhe" name="fr_lienhe" method="POST" action="">
        <div id="noidunglienhe">
            <div class="noidung"><h2>send messages</h2></div>
            <div class="noidung">
                <label >Name:<span style="color: red;">(*)</span></label>
                <input type="text" id="name" name="name" size="40"/>
            </div >
            <div class="noidung">
                <label>Email:<span style="color: red;">(*)</span></label>
                <input type="text" id="email" name="email" size="40"/>
            </div>
            <div class="noidung">
                <label>Content:<span style="color: red;">(*)</span></label>
                <textarea id="noidung" cols="40" rows="12" name="noidung"></textarea> 
            </div>
            <div class="noidung">
                <input type="submit" id="send" value="send" name="send"/>
            </div>
        </div>
    </form>
</div>
';
echo $content;
?>
